home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / tbox3_21.zip / install.exe / Install.cmd < prev    next >
OS/2 REXX Batch file  |  1997-08-09  |  4KB  |  133 lines

  1. /*  K.A.Ash (c) Copyright 1996                                          */
  2. /*  install.cmd                                                         */
  3. /*  -----------                                                         */
  4. /*      A very simple installation script.                              */
  5.  
  6. options etmode
  7. options exmode
  8. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  9. call SysLoadFuncs
  10.  
  11. programName = SysSearchPath('PATH', 'TaskBox.exe')
  12. if programName = '' then
  13. do
  14.    say 'Error: Could not find TaskBox.exe in PATH directories.'
  15.    exit
  16. end
  17.  
  18. if stream('TaskBox.dll', 'command', 'query exists') = '' then
  19. do
  20.    say 'Error: Could not find TaskBox.dll in the current directory.'
  21.    exit 1
  22. end
  23.  
  24. DEST=''
  25. do while DEST=''
  26.   DEST = GetAnswer( "<WP_DESKTOP>", "Enter directory to install TaskBox objects" )
  27.   /* make dir fully qualified */
  28.   if( SubStr( DEST,1,1) \= '<' & SubStr( DEST,2,2)\=':\' ) then do
  29.     DEST = GetFullQualifiedPath( DEST )
  30.   end
  31.  
  32.   /* should check if destination is valid dir */
  33.   if( DEST = '' ) then Say "Invalid directory selected"
  34. end /* do while */
  35.  
  36. if SysCreateObject('WPProgram', 'TaskBox', DEST,,
  37.          'EXENAME='programName';STARTUPDIR='directory() || ,
  38.          ';PROGTYPE=PM;OBJECTID=<TaskBox>;PARAMETERS=/WATCH 20 /P:F:0%',,
  39.          'u') = 0 then
  40.    say 'Error: Could not create object.'
  41. else
  42.    say 'The program object was successfully created in 'DEST
  43.  
  44. CALL inst_modules
  45.  
  46. if SysSearchPath('PATH', 'e.exe') \='' then
  47. do
  48.   ANS = SubStr( GetAnswer( "Y", "View TaskBox.txt now(Y/N) ?" ), 1, 1)
  49.   if (  (ANS = 'Y') | (ANS = 'y') ) then
  50.       "e.exe TaskBox.txt"
  51. end
  52. exit
  53.  
  54. exit 0
  55.  
  56. inst_modules:
  57.  
  58. IF SysFileTree( "module.1st", "file", "FOS" ) THEN DO
  59.          SAY 'Error: SysFileTree failed'
  60.          RETURN
  61.          END
  62.  
  63. DO i = 1 to file.0
  64.      j = LASTPOS( '\', file.i )
  65.      IF j ¬= 0 THEN j = j - 1
  66.      CALL do_module SUBSTR( file.i, 1, j )
  67. END
  68.  
  69. RETURN
  70.  
  71. do_module:      /* arg directory containing module.1st */
  72. ARG     dir
  73. file = dir||'\module.1st'
  74. module = LINEIN( file )
  75. DO WHILE LINES( file )
  76.         line =LINEIN( file )
  77.         IF line = "COMMAND:" THEN LEAVE
  78.         SAY line
  79. END
  80.  
  81. Say 'Do you wish to install "'module'"(Yes/No) ?'
  82. PULL ans .
  83. IF SUBSTR(ans,1,1) = 'Y' THEN DO
  84.      '@copy 'dir||'\'||module' . '
  85.      IF rc = 0 THEN
  86.        IF line = 'COMMAND:' THEN DO
  87.                         cur_dir = DIRECTORY()
  88.                         CALL DIRECTORY( dir )
  89.                         DO WHILE LINES( file )
  90.                            cmd = LINEIN( file )
  91.                            INTERPRET cmd
  92.                            END
  93.                         CALL DIRECTORY( cur_dir )
  94.                         END
  95.      IF rc = 0 THEN SAY module' installed.'
  96.      ELSE SAY 'Failed to install 'module
  97.      END
  98. ELSE
  99.      SAY 'Skiping this "'module'"'
  100. RETURN
  101.  
  102. GetAnswer:
  103.  parse arg DEFAULT, MSG
  104.  
  105.  say;
  106.  call Charout, MSG '['DEFAULT'] : ';
  107.  parse pull ANS;
  108.  if (Length(ANS) > 0) then
  109.     return(ANS);
  110.  else
  111.     return(DEFAULT);
  112.  
  113. GetFullQualifiedPath:
  114.  parse arg SRC
  115.  DEST = ''
  116.  if( SubStr( SRC,2,1) = ':' ) then do
  117.      CURDIR = Directory()
  118.      NEWDIR = Directory( SubStr(SRC,1,2) )
  119.      if( Length( NEWDIR) = 3 & SubStr( NEWDIR,3,1) = '\' ) then
  120.         NEWDIR = SubStr( NEWDIR, 1,2 )
  121.      if( NEWDIR \= '' ) then do
  122.         DEST = NEWDIR'\'SubStr( SRC,3)
  123.      end  /* Do */
  124.      call Directory CURDIR
  125.  end  /* Do */
  126.  else do
  127.      DIR = Directory()
  128.      if( Length( DIR) = 3 & SubStr( DIR,3,1) = '\' ) then
  129.         DIR = SubStr( DIR, 1,2 )
  130.      DEST = DIR'\'SRC
  131.  end  /* Do */
  132. return (DEST)
  133.